namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0134 : DbMigration
    {
        public override void Up()
        {
            DropTable("dbo.hrm_ps_time_attendants");
            DropTable("dbo.hrm_ps_time_att_monthly");

            DropForeignKey("dbo.HrmPsTimeAttendant", "EmpId", "dbo.hrm_ps_employees");
            DropIndex("dbo.HrmPsTimeAttendant", new[] { "EmpId" });
            CreateTable(
                "dbo.hrm_ps_time_attendants",
                c => new
                    {
                        working_seq = c.Int(nullable: false, identity: true),
                        working_date = c.DateTime(),
                        emp_seq = c.Int(),
                        working_status = c.String(),
                        working_start = c.Time(),
                        working_end = c.Time(),
                        remarks = c.String(),
                        record_status = c.String(),
                        created_by = c.Int(),
                        created_when = c.DateTime(),
                        updated_by = c.Int(),
                        updated_when = c.DateTime(),
                    })
                .PrimaryKey(t => t.working_seq)
                .ForeignKey("dbo.hrm_ps_employees", t => t.emp_seq)
                .Index(t => t.emp_seq);
            
            CreateTable(
                "dbo.hrm_ps_time_att_monthly",
                c => new
                    {
                        time_att_month_seq = c.Int(nullable: false, identity: true),
                        emp_seq = c.Int(),
                        working_month = c.Int(),
                        plan_working_day_count = c.Int(),
                        actual_working_day_count = c.Int(),
                        valid_absence_day_count = c.Decimal(precision: 18, scale: 2),
                        invalid_absence_day_count = c.Decimal(precision: 18, scale: 2),
                        late_day_count = c.Int(),
                        sick_day_count = c.Decimal(precision: 18, scale: 2),
                        private_day_count = c.Decimal(precision: 18, scale: 2),
                        vacation_day_count = c.Decimal(precision: 18, scale: 2),
                        working_year = c.Int(),
                        sick_count = c.Int(),
                        quota_vacation = c.Int(),
                        deliver_day_count = c.Int(),
                        edu_day_count = c.Int(),
                        ordain_day_count = c.Int(),
                        temp_day_count = c.Int(),
                        remarks = c.String(),
                        record_status = c.String(),
                        created_by = c.Int(),
                        created_when = c.DateTime(),
                        updated_by = c.Int(),
                        updated_when = c.DateTime(),
                    })
                .PrimaryKey(t => t.time_att_month_seq)
                .ForeignKey("dbo.hrm_ps_employees", t => t.emp_seq)
                .Index(t => t.emp_seq);
            
            DropTable("dbo.HrmPsTimeAttendant");
        }
        
        public override void Down()
        {
            CreateTable(
                "dbo.HrmPsTimeAttendant",
                c => new
                    {
                        WorkingId = c.Int(nullable: false, identity: true),
                        WorkingDate = c.DateTime(),
                        EmpId = c.Int(),
                        WorkingStatus = c.String(),
                        WorkingStart = c.Time(),
                        WorkingEnd = c.Time(),
                        Remarks = c.String(),
                        RecordStatus = c.String(),
                        CreatedBy = c.Int(),
                        CreatedWhen = c.DateTime(),
                        UpdatedBy = c.Int(),
                        UpdatedWhen = c.DateTime(),
                    })
                .PrimaryKey(t => t.WorkingId);
            
            DropIndex("dbo.hrm_ps_time_att_monthly", new[] { "emp_seq" });
            DropIndex("dbo.hrm_ps_time_attendants", new[] { "emp_seq" });
            DropForeignKey("dbo.hrm_ps_time_att_monthly", "emp_seq", "dbo.hrm_ps_employees");
            DropForeignKey("dbo.hrm_ps_time_attendants", "emp_seq", "dbo.hrm_ps_employees");
            DropTable("dbo.hrm_ps_time_att_monthly");
            DropTable("dbo.hrm_ps_time_attendants");
            CreateIndex("dbo.HrmPsTimeAttendant", "EmpId");
            AddForeignKey("dbo.HrmPsTimeAttendant", "EmpId", "dbo.hrm_ps_employees", "emp_seq");
        }
    }
}
